#827 fix boolpredicate validation - #828
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes issue #827 where supplying a predicate function for OpenAPIBackend’s validate option was being coerced to true, preventing conditional validation from working.
Changes:
- Rename
BoolPredicatetoContextPredicateand update thevalidateoption/member types accordingly. - Fix
OpenAPIBackendconstructor to preserve thevalidateoption value (boolean or predicate) instead of coercing it. - Add tests covering predicate-based validation behavior (skip vs run validation).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/backend.ts | Updates predicate type name and fixes validate assignment to avoid boolean coercion. |
| src/backend.test.ts | Adds regression tests ensuring validate predicates are invoked and affect validation flow. |
Comments suppressed due to low confidence (1)
src/backend.ts:75
- Renaming the exported
BoolPredicatetype toContextPredicateis a breaking public API change for TypeScript consumers (they may importBoolPredicatetoday), but the package version is still on the v5 minor line. Consider keeping a backward-compatible alias export (e.g.export type BoolPredicate = ContextPredicatewith a@deprecatedtag) so existing imports keep compiling while still steering users to the new name.
export type HandlerMap = { [operationId: string]: Handler | undefined };
export type ContextPredicate = (context: Context, ...args: any[]) => boolean;
/**
* The different possibilities for set matching.
*
* @enum {string}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for the fix and sorry for the slow response! Nice catch — I traced the This'll go out as a minor rather than a patch, since predicates actually taking effect is a real behaviour change for anyone already passing one. I'll follow up with docs for the option. Generated by Claude Code |
|
This is released as part of |
Closes #827
OpenAPIBackendconstructor fixed to properly assign thevalidateoption as a member.BoolPredicateto the more precise, less redundantContextPredicatevalidatevalue